(() => {

    class Model {

        // 成员变量
        private name: string;
        private value: string;

        // 构造方法
        constructor(name: string, value: string) {
            this.name = name;
            this.value = value;
        }

        // 成员函数
        public sayHi(): void {
            console.log(`hello ${this.name}`);
        }

    }

    let m: Model = new Model('yejing', 'guagnzhou');
    m.sayHi();


    // 继承

    class Animal {

        // 私有成员属性，在其他类，包括子类都是不可见的
        private name: string;
        private food: string;

        // 通过下面的共有的方法进行访问
        public getName(): string {
            return this.name;
        }

        public getFood(): string {
            return this.food;
        }

        constructor(name: string, food: string) {
            this.name = name;
            this.food = food;
        }

        public eat(): void {
            console.log(`${this.name} eat ${this.food}`)
        }
    }

    class Dog extends Animal {
        public eat(): void {
            super.eat();
            console.log(`${this.getName()} 大口吃 ${this.getFood()}`)
        }
    }

    let d: Dog = new Dog('旺财', '肉');
    d.eat();


    // static 和 instanceof


    // 实现接口

    interface IFly {
        fly(): void
    }


    interface ISwim {
        swim(): void
    }


    // 实现多个接口
    class Person implements IFly, ISwim {
        swim(): void {
            console.log('我是超人，我会游泳')
        }


        fly(): void {
            console.log('我是超人，我会飞')
        }


    }

    let a = new Person()

    a.fly()
    a.swim()

    // 接口可以继承接口
    interface Foo extends IFly, ISwim {

    }

    class Person2 implements Foo {
        swim(): void {
            console.log('我是超人2，我会游泳')
        }


        fly(): void {
            console.log('我是超人2，我会飞')
        }


    }

    let p3 = new Person2()

    p3.fly()
    p3.swim()

})()